﻿using blackhouse.BlackApart.Business.Reservations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace blackhouse.BlackApart.Business {
    public static class BlackApartHelper {

        public static string PrintStayPeriod(this IWebReservation reservation, bool printLengthOfStay = true) {
            DateTime adt = reservation.ArrivalDate;
            DateTime ddt = reservation.DepartureDate;
            if (adt.Hour < 14)
                adt = adt.AddDays(-1);
            string r = adt.FormatDateRange(ddt);
            if (printLengthOfStay)
                r = r + " (" + reservation.PrintLegthOfStay() + ")";
            return r;
        }

        public static string PrintLegthOfStay(this IWebReservation reservation) {
            DateTime adt = reservation.ArrivalDate;
            DateTime ddt = reservation.DepartureDate;
            if (adt.Hour < 14)
                adt = adt.AddDays(-1);
            string s = "noc";
            int los = (int)(ddt.Date - adt.Date).TotalDays;
            if (los > 1 && los <= 4)
                s = "noce";
            if (los > 4)
                s = "nocy";
            return los + " " + s;
        }

        public static string PrintArrivalDateTime(this IWebReservation reservation) {
            string f = "H:mm - dddd";
            if (reservation.ArrivalDate.Hour < 14)
                f = "H:mm - ddd, d MMMM yyyy";
            return reservation.ArrivalDate.ToString(f);
        }

    }
}
